#include "spi.h"

#include <stdio.h>
#include <string.h>


int SPI_example() {
	int spi_ch = 0;
	int i;
	char buf[] = {0xAA, 0xAA, 0x00, 0xFF, 0x55, 0x55}; 
	
	/* open device wiht channel and baudrate */
	SPI_open(spi_ch, 10000000);
	
	/* enable the chip-select line */
	SPI_enable(spi_ch);
	
	for(i = 0; i < sizeof(buf); i ++) {
		/* write data and read back */
		buf[i] = SPI_write(spi_ch, buf[i]);
	}
	
	/* disable the chip-select line */
	SPI_disable(spi_ch);
	
	/* close device */
	SPI_close(spi_ch);
	return 0;
}
